
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets" template="/template/main_list.xhtml">
	
 	<ui:param name="resultList" value="#{obraListMB.resultList}"/>
 	<ui:param name="tituloLista" value="#{messages['obra.list.table.title']}"/>
 	
	<ui:define name="botoes">

		<p:commandButton title="#{messages['button.new']}" icon="ui-icon-document" action="#{obraListMB.getNextView}"
			actionListener="#{obraListMB.clear}" ajax="false" />

		<p:commandButton title="#{messages['button.delete']}" icon="ui-icon-trash" onclick="confirmation.show()"
			type="button" immediate="true" ajax="false" />

		<p:confirmDialog message="#{messages['label.confirm.delete']}" showEffect="bounce" hideEffect="explode"
			header="#{messages['label.dialog.alert']}!" severity="alert" widgetVar="confirmation">

			<h:commandButton value="#{messages['button.dialog.yes']}" action="#{obraListMB.deleteSelection}"
				actionListener="#{obraListMB.clear}" />
			<h:commandButton value="#{messages['button.dialog.no']}" onclick="confirmation.hide()" type="button" />
		</p:confirmDialog>

	</ui:define>
	
	<ui:define name="filtro">

			<p:fieldset legend="#{messages['filtrar.obra']}" toggleable="true" toggleSpeed="500">	
				<h:panelGrid columns="2">
					<h:outputLabel value="#{messages['obra.label.unidadeOrcamentaria']}: " for="unidadeOrcamentaria" styleClass="text-input" />
					<h:panelGrid columns="5">
						<h:selectOneMenu value="#{obraListMB.unidadeOrcamentaria}" id="unidadeOrcamentaria" style="width: 350px;"
							title="#{messages['obra.label.unidadeOrcamentaria']}" 
							requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}">
							<f:selectItem itemLabel="Selecione" itemValue="" />	
	 						<f:selectItems value="#{obraListMB.unidadeOrcamentarias}"></f:selectItems>
						</h:selectOneMenu>
					    <p:message for="unidadeOrcamentaria" />

				    	<h:outputLabel value="#{messages['obra.label.anoExercicio']}: " for="anoExercicio" styleClass="text-input" /> 
				    	<h:inputText id="anoExercicio" value="#{obraListMB.anoExercicio}" title="#{messages['obra.alt.anoExercicio']}" size="4" maxlength="4" />
				    	<p:message for="anoExercicio" />

					</h:panelGrid>

					<h:outputLabel value="#{messages['obra.label.dataCadastro']}: " for="dataCadastroInicial" styleClass="text-input" />
					<h:panelGrid columns="5">
						<p:calendar id="dataCadastroInicial" value="#{obraListMB.dataCadastroInicial}"
						   pattern="#{messages['label.date.pattern']}" navigator="true" showButtonPanel="true"
						   locale="#{currentLocale}" title="#{messages['obra.label.dataCadastro']}" />
						   <p:message for="dataCadastroInicial" />
	
						<h:outputLabel value="#{messages['obra.label.periodoFinalItem']}: " for="dataCadastroFinal" styleClass="text-input" />
						<p:calendar id="dataCadastroFinal" value="#{obraListMB.dataCadastroFinal}"
						   pattern="#{messages['label.date.pattern']}" navigator="true" showButtonPanel="true"
						   locale="#{currentLocale}" title="#{messages['obra.label.periodoFinalItem']}" />
						   <p:message for="dataCadastroFinal" />
					</h:panelGrid>
				</h:panelGrid>

			    <h:commandButton value="#{messages['button.pesquisar']}"  action="#" ajax="true" >
		    		<f:ajax execute="list" render="list" />
		    	</h:commandButton>

			</p:fieldset>	
	</ui:define>
	
	<ui:define name="colunaMarcacao">
			<p:column style="width:1%;">
				<h:selectBooleanCheckbox value="#{obraListMB.selection[bean.id]}"></h:selectBooleanCheckbox>
			</p:column>
	</ui:define>

	<ui:define name="colunas">
	 	<ui:param name="obraListMB" value="#{obraListMB}"/>
			
			<p:column style="width:5%;" sortBy="#{bean.id}">
				<f:facet name="header">#{messages['obra.label.id']}</f:facet>
				<h:outputText value="#{bean.id}" />
			</p:column>
					
			<p:column sortBy="#{bean.unidadeOrcamentaria.descricao}">
				<f:facet name="header">#{messages['obra.label.unidadeOrcamentaria']}</f:facet>
				<h:commandLink action="#{obraListMB.getNextView}" actionListener="#{obraListMB.clear}">
					<h:outputText value="#{bean.unidadeOrcamentaria.descricao}" />
					<f:param name="id" value="#{bean.id}" />
				</h:commandLink>
			</p:column>

			<p:column sortBy="#{bean.titulo}">
				<f:facet name="header">#{messages['obra.label.titulo']}</f:facet>
				<h:commandLink action="#{obraListMB.getNextView}" actionListener="#{obraListMB.clear}">
					<h:outputText value="#{bean.titulo}" />
					<f:param name="id" value="#{bean.id}" />
				</h:commandLink>
			</p:column>
			<p:column sortBy="#{bean.dataCadastro}">
				<f:facet name="header">#{messages['obra.label.dataCadastro']}</f:facet>
				<h:commandLink action="#{obraListMB.getNextView}" actionListener="#{obraListMB.clear}">
					<h:outputText value="#{bean.dataCadastro}" />
					<f:param name="id" value="#{bean.id}" />
				</h:commandLink>
			</p:column>

			<p:column sortBy="#{bean.anoExercicio}">
				<f:facet name="header">#{messages['obra.label.anoExercicio']}</f:facet>
				<h:commandLink action="#{obraListMB.getNextView}" actionListener="#{obraListMB.clear}">
					<h:outputText value="#{bean.anoExercicio}" />
					<f:param name="id" value="#{bean.id}" />
				</h:commandLink>
			</p:column>

			<p:column sortBy="#{bean.situacaoObra.descricao}">
				<f:facet name="header">#{messages['obra.label.situacaoObra']}</f:facet>
				<h:commandLink action="#{obraListMB.getNextView}" actionListener="#{obraListMB.clear}">
					<h:outputText value="#{bean.situacaoObra.descricao}" />
					<f:param name="id" value="#{bean.id}" />
				</h:commandLink>
			</p:column>
	</ui:define>
</ui:composition>